package com.example.springboot.utils;

import org.lionsoul.ip2region.xdb.Searcher;

import java.io.IOException;

/**
 * @Author:ChenZhangKun
 * @Date: 2022/7/31 19:00
 */
public class IpRegionUtil {
    public static String city(String ip) throws Exception {
        String dbPath = "F:\\IdeaProjects\\springboot\\src\\main\\resources\\db\\ip2region.db";
        Searcher searcher = null;
        try {
            searcher = Searcher.newWithFileOnly(dbPath);
        } catch (IOException ex) {

        }
        String search = searcher.search(ip);
        return search;
    }

    public static void main(String[] args) throws Exception {
        System.out.println(city("117.173.224.173"));
    }
}
